package com.ksd.pug.controller.hotelbrand;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ksd.pug.service.hotelbrand.IHotelBrandService;
import com.ksd.pug.pojo.HotelBrand;
import com.ksd.pug.vo.HotelBrandVo;
import com.ksd.pug.commons.enums.ResultStatusEnumA;
import com.ksd.pug.commons.ex.PugValidationException;
import com.ksd.pug.commons.utils.fn.asserts.Vsserts;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.ksd.pug.controller.BaseController;
import java.util.List;

/**
 * HotelBrandController
 * 创建人:yykk<br/>
 * 时间：2022-04-18 01:07:10 <br/>
 * 源码下载：前台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-ui.git
 * 飞哥B站地址：后台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-parent.git
 * @version 1.0.0<br/>
 *
*/

@RestController
@RequiredArgsConstructor
@Slf4j
public class HotelBrandController extends BaseController{

    private final IHotelBrandService hotelbrandService;


    /**
     * 查询酒店品牌列表信息
     * @path : /admin/hotelbrand/load
     * @method: findHotelBrands
     * @result : List<HotelBrand>
     * 创建人:yykk
     * 创建时间：2022-04-18 01:07:10
     * @version 1.0.0
     * @return
     */
    @GetMapping("/hotelbrand/load")
    public List<HotelBrand> findHotelBrandList() {
        return hotelbrandService.findHotelBrandList();
    }

	/**
	 * 查询酒店品牌列表信息并分页
	 * @path : /admin/hotelbrand/list
     * @method: findHotelBrands
     * @param : hotelbrandVo
     * @result : IPage<HotelBrand>
	 * 创建人:yykk
	 * 创建时间：2022-04-18 01:07:10
	 * @version 1.0.0
	*/
    @PostMapping("/hotelbrand/list")
    public IPage<HotelBrand> findHotelBrands(@RequestBody HotelBrandVo hotelbrandVo) {
        return hotelbrandService.findHotelBrandPage(hotelbrandVo);
    }


    /**
     * 根据酒店品牌id查询明细信息
     * @method: get/{id}
     * @path : /admin/hotelbrand/get/{id}
     * @param : id
     * @result : HotelBrand
     * 创建人:yykk
     * 创建时间：2022-04-18 01:07:10
     * @version 1.0.0
    */
    @GetMapping("/hotelbrand/get/{id}")
    public HotelBrand getHotelBrandById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
           throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return hotelbrandService.getHotelBrandById(new Long(id));
    }


	/**
	 * 保存和修改酒店品牌
     * @method: saveupdate
	 * @path : /admin/hotelbrand/save
     * @param : hotelbrand
     * @result : HotelBrand
	 * 创建人:yykk
	 * 创建时间：2022-04-18 01:07:10
	 * @version 1.0.0
	*/
    @PostMapping("/hotelbrand/saveupdate")
    public HotelBrand saveupdateHotelBrand(@RequestBody HotelBrand hotelbrand) {
        return hotelbrandService.saveupdateHotelBrand(hotelbrand);
    }


    /**
	 * 根据酒店品牌id删除酒店品牌
     * @method: delete/{id}
     * @path : /admin/hotelbrand/delete/{id}
     * @param : id
     * @result : int
	 * 创建人:yykk
	 * 创建时间：2022-04-18 01:07:10
	 * @version 1.0.0
	*/
    @PostMapping("/hotelbrand/delete/{id}")
    public int deleteHotelBrandById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return hotelbrandService.deleteHotelBrandById(new Long(id));
    }


   /**
   	 * 根据酒店品牌ids批量删除酒店品牌
     * @method: hotelbrand/delBatch
     * @path : /admin/hotelbrand/delBatch
     * @param : hotelbrandVo
     * @result : boolean
   	 * 创建人:yykk
   	 * 创建时间：2022-04-18 01:07:10
   	 * @version 1.0.0
   	*/
    @PostMapping("/hotelbrand/delBatch")
    public boolean delHotelBrand(@RequestBody HotelBrandVo hotelbrandVo) {
        log.info("你要批量删除的IDS是:{}", hotelbrandVo.getBatchIds());
        if (Vsserts.isEmpty(hotelbrandVo.getBatchIds())) {
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return hotelbrandService.delBatchHotelBrand(hotelbrandVo.getBatchIds());
    }

}